<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<a href="javascript:toSelectUser()" class="btn1">关联用户</a>
<a href="javascript:toSelectRight()" class="btn1">关联权限</a>

<script type="text/javascript">
<!--

var httpController = new HttpController();
var contextPath = controller.getContextPath();
var roleId = "";

//到选择用户页面
function toSelectUser() {
	if(controller.checkSelect('single') == true) {
		roleId = controller.getSelectId();
		controller.openWindow(contextPath + "/admin/sysman/user/userSelect.jsp?tableName=SYSMAN_USER",1000,600,'userSelect');
	}
}
//选择用户后的回调方法
function doAfterSelect(selectArr) {
	var selectValues = "";
	var len = selectArr.length;
	for(var i = 0;i<len;i++) {
		var obj = selectArr[i];
		selectValues += "," + obj["ID"];
	}
	if(selectValues != "") {
		selectValues = selectValues.substring(1);
	}

	//保存角色与用户的关系
	//alert(selectValues);
	httpController.executeHttp(contextPath + "/services?action=sysman.SysmanAction&operate=doSaveRoleUser&roleId=" + roleId+"&userIds=" + selectValues, function(result) {
		//alert(result);
		if(result == '1') {
			alert("设置成功！");
		} else {
			alert("设置失败！");
		}
	});
	
}

//到选择权限页面
function toSelectRight() {
	if(controller.checkSelect('single') == true) {
		roleId = controller.getSelectId();
		controller.openWindow(contextPath + "/admin/sysman/right/rightSelect.jsp?tableName=SYSMAN_RIGHT",230,600,'rightSelect');
	}
}
//选择权限后的回调方法
function doAfterSelectTree(selectValues) {
	//alert(selectValues);
	httpController.executeHttp(contextPath + "/services?action=sysman.SysmanAction&operate=doSaveRoleRight&roleId=" + roleId+"&rightIds=" + selectValues, function(result) {
		//alert(result);
		if(result == '1') {
			alert("设置成功！");
		} else {
			alert("设置失败！");
		}
	});
}

//-->
</script>
